package org.zju.demo.service.impl;

import org.zju.demo.model.ProductCategory;
import org.zju.demo.service.intf.ProductCategoryIntf;
import org.zju.demo.utils.HibernateUtil;

import java.util.List;

/**
 * Created by admin on 2015/8/27.
 */
public class ProductCategoryImpl implements ProductCategoryIntf {
    public List<ProductCategory> findByCategoryId(int categoryId) {
        String hql = "from ProductCategory where categoryId=?";
        String[] parameters = {Integer.toString(categoryId)};
        List<ProductCategory> list = HibernateUtil.executeQuery(hql, parameters);
        return list;
    }

    public List<ProductCategory> findByProductId(int productId) {
        String hql = "from ProductCategory where productId=?";
        String[] parameters = {Integer.toString(productId)};
        List<ProductCategory> list = HibernateUtil.executeQuery(hql, parameters);
        return list;
    }
}
